package com.stx.design.chain;

import java.util.ArrayList;
import java.util.List;

public class ChainManager implements IBaseTask{

	private List<IBaseTask> taskList = new ArrayList<IBaseTask>();
	private int index = 0;
	
	public void addTask(IBaseTask task){
		taskList.add(task);
	}
	
	@Override
	public void doAction(String isTask, IBaseTask ibaseTask) throws Exception {
		if(index >= taskList.size()){
			throw new Exception("out of range");
		}
		IBaseTask task =  taskList.get(index);
		index++;
		task.doAction(isTask, ibaseTask);
	}

}
